package com.huazhi.wzsnw.service.impl;

import com.huazhi.wzsnw.mapper.DepartmentMapper;
import com.huazhi.wzsnw.model.Department;
import com.huazhi.wzsnw.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DepartmentServiceImpl implements DepartmentService {
    @Autowired
    private DepartmentMapper departmentMapper;

    @Override
    public int save(Department record) {
        departmentMapper.insertSelective(record);
        return 0;
    }

    @Override
    public int delete(Department record) {
        departmentMapper.deleteByPrimaryKey(record.getTid());
        return 0;
    }

    @Override
    public int deletes(List<Department> records) {
        return 0;
    }

    @Override
    public int update(Department record) {
        departmentMapper.updateByPrimaryKeySelective(record);
        return 0;
    }

    @Override
    public Department findByTid(String tid) {
        return departmentMapper.selectByPrimaryKey(tid);
    }

    @Override
    public List<Department> findPagingByListTid(List<String> stringList, Integer pageIndex, Integer pageSize) {
        return departmentMapper.findPagingByListTid(stringList,pageIndex,pageSize);
    }

    @Override
    public List<String> getDepartmentBySearch(String search) {
        return departmentMapper.selectDepartmentBySearch(search);
    }

    @Override
    public Department getDepartmentByField(String field, String value) {
        return departmentMapper.selectDepartmentByField(field,value);
    }

    @Override
    public Department getDepartmentByTidExist(String tid, String departmentname) {
        return departmentMapper.selectDepartmentByTidExist(tid,departmentname);
    }

    @Override
    public List<Department> getList() {
       return departmentMapper.selectList();
    }
}
